<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>施工/维护人员注册</title>
<meta name="viewport" content="initial-scale=1, maximum-scale=1">
<link rel="shortcut icon" href="/favicon.ico">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black">

<link rel="stylesheet"
	href="//g.alicdn.com/msui/sm/0.6.2/css/sm.min.css">
<link rel="stylesheet"
	href="//g.alicdn.com/msui/sm/0.6.2/css/sm-extend.min.css">
	<jsp:include page="../inc/head.jsp" />
</head>
<body>
<jsp:include page="../inc/header.jsp" />
<div class="am-cf admin-main">
<!-- content start -->
<div class="admin-content">
  <div class="admin-content-body">
  
  <form action="${basePath}/3/personalregister" onsubmit="return checkMsg()">
  

    <div class="am-cf am-padding am-padding-bottom-0">
      <div class="am-fl am-cf">
        <strong class="am-text-primary am-text-lg">${pagetitle}</strong> /
        <small>${subtitle}</small>
      </div>
    </div>

    <hr>

    <div class="am-tabs am-margin" data-am-tabs>
      <ul class="am-tabs-nav am-nav am-nav-tabs">
        <li class="am-active"><a href="#tab1">用户注册</a></li>
      </ul>

      <div class="am-tabs-bd am-tabs-bd-ofv">
        <div class="am-tab-panel am-fade am-in am-active" id="tab1">
         <div class="am-g am-margin-top" style="margin-left: 37%;">
              <div class="am-u-sm-4 am-u-md-2">
           		<img class="am-circle" alt="头像" src="${headimgurl}" width="80" height="80"/>
              </div>  
        </div>  

        <div class="am-g am-margin-top">
              <div class="am-u-sm-4 am-u-md-2 am-text-right">
            公司编码：
              </div>
              <div class="am-u-sm-8 am-u-md-4 am-u-end col-end">
               	<input type="text" id="orgCode" name="orgCode" onblur="orgCodeTest(this)" class="am-input-sm am-form-field">
              </div>
        </div>

    	<div class="am-g am-margin-top">
              <div class="am-u-sm-4 am-u-md-2 am-text-right">
                姓名：
              </div>
              <div class="am-u-sm-8 am-u-md-4 am-u-end col-end">
                <input type="text" id="realName" name="realName" class="am-input-sm am-form-field">
              </div>
       </div>

          <div class="am-g am-margin-top">
              <div class="am-u-sm-4 am-u-md-2 am-text-right">
                手机：
              </div>
              <div class="am-u-sm-8 am-u-md-4 am-u-end col-end">
                <input type="text" id="cellPhone" name="cellPhone" class="am-input-sm am-form-field">
              </div>
            </div>

        </div>
      </div>
    </div>

    <div class="am-margin">
      <input type="submit" class="am-btn am-btn-primary am-round">
      <input type="reset" class="am-btn am-btn-primary am-round">
    </div>
    
    
	  <div class="am-g am-margin-top">
         <input type="text" name="operate" value="register" hidden="true">
      </div>
      
		<div class="am-g am-margin-top">
	         <input type="text" name="openid" value="${openid}" hidden="true">
	    </div>
	    
	    <div class="am-g am-margin-top">
	         <input type="text" name="headImgUrl" value="${headimgurl}" hidden="true">
	    </div>
	    
</form>
  </div>


</div>
<!-- content end -->

</div>

<!--[if lt IE 9]>
<script src="http://libs.baidu.com/jquery/1.11.1/jquery.min.js"></script>
<script src="http://cdn.staticfile.org/modernizr/2.8.3/modernizr.js"></script>
<script src="assets/js/amazeui.ie8polyfill.min.js"></script>
<![endif]-->

<!--[if (gte IE 9)|!(IE)]><!-->
<script src="${basePath}assets/js/jquery.min.js"></script>
<!--<![endif]-->
<script src="${basePath}assets/js/amazeui.min.js"></script>
<script src="${basePath}assets/js/app.js"></script>

<script type="text/javascript">

	function checkMsg(){
		
	    var reg = new RegExp("^[0-9]*$");  
		
		
	    var codeOrg = $("#orgCode").val(); 
	    var cellPhone = $("#cellPhone").val();
	    var realname = $("#realName").val();
	    
	    codeOrg = codeOrg.replace(/\s+/g,"");
	    cellPhone = cellPhone.replace(/\s+/g,"");
	    realname = realname.replace(/\s+/g,"");
	    
	    if(codeOrg==null||codeOrg==""||cellPhone==null||cellPhone==""||realname==null||realname==""){
	    	alert("请完整输入个人信息！");
	    	return false;
	    }
	    var f=orgChecker(codeOrg);
	    if(reg.test(codeOrg) && f.key){
	    	if(reg.test(cellPhone)){
	    		if(realname == ""){
	    			 alert("需要输入姓名!");    
				        return false;
	    		}
	    	}else{
	    		  alert("手机号码格式不正确!");
	    		  
	    		  return false;
	    	}
	    }else{
	    	 alert("机构编码不正确!"); 
	    	return false;
	    }
	    
	  return true;
	 
	}

	function orgChecker(code){
		var res;
		$.ajax({
			async:false,
            type : 'get',
            dataType : 'json',
            cache : false,
            url : "${basePath}orgcodecheker/"+code,
            success : function(data) {
            	if(data.key){
            		res=data;
            	}else{
                    res=data;
            	}
            }
		});
		return res;
	}
	
	function orgCodeTest(obj){
		var code=$(obj).val();
		var res= orgChecker(code);
		if(res.key){
			alert('公司名称：'+res.org);
		}else{
			alert('错误：公司编码不存在');
		}
	}
</script>

</body>
</html>

